home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / include / libpurple / imgstore.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-04  |  5.2 KB  |  190 lines

  1. /**
  2.  * @file imgstore.h IM Image Store API
  3.  * @ingroup core
  4.  *
  5.  * purple
  6.  *
  7.  * Purple is the legal property of its developers, whose names are too numerous
  8.  * to list here.  Please refer to the COPYRIGHT file distributed with this
  9.  * source distribution.
  10.  *
  11.  * This program is free software; you can redistribute it and/or modify
  12.  * it under the terms of the GNU General Public License as published by
  13.  * the Free Software Foundation; either version 2 of the License, or
  14.  * (at your option) any later version.
  15.  *
  16.  * This program is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  * GNU General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU General Public License
  22.  * along with this program; if not, write to the Free Software
  23.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  24.  *
  25.  */
  26. #ifndef _PURPLE_IMGSTORE_H_
  27. #define _PURPLE_IMGSTORE_H_
  28.  
  29. #include <glib.h>
  30.  
  31. struct _PurpleStoredImage;
  32. typedef struct _PurpleStoredImage PurpleStoredImage;
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. /**
  39.  * Add an image to the store.
  40.  *
  41.  * The caller owns a reference to the image in the store, and must dereference
  42.  * the image with purple_imgstore_unref() for it to be freed.
  43.  *
  44.  * No ID is allocated when using this function.  If you need to reference the
  45.  * image by an ID, use purple_imgstore_add_with_id() instead.
  46.  *
  47.  * @param data        Pointer to the image data, which the imgstore will take
  48.  *                      ownership of and free as appropriate.  If you want a
  49.  *                      copy of the data, make it before calling this function.
  50.  * @param size        Image data's size.
  51.  * @param filename    Filename associated with image.
  52.  *
  53.  * @return The stored image.
  54.  */
  55. PurpleStoredImage *
  56. purple_imgstore_add(gpointer data, size_t size, const char *filename);
  57.  
  58. /**
  59.  * Add an image to the store, allocating an ID.
  60.  *
  61.  * The caller owns a reference to the image in the store, and must dereference
  62.  * the image with purple_imgstore_unref_by_id() or purple_imgstore_unref()
  63.  * for it to be freed.
  64.  *
  65.  * @param data        Pointer to the image data, which the imgstore will take
  66.  *                      ownership of and free as appropriate.  If you want a
  67.  *                      copy of the data, make it before calling this function.
  68.  * @param size        Image data's size.
  69.  * @param filename    Filename associated with image.
  70.  
  71.  * @return ID for the image.
  72.  */
  73. int purple_imgstore_add_with_id(gpointer data, size_t size, const char *filename);
  74.  
  75. /**
  76.  * Retrieve an image from the store. The caller does not own a
  77.  * reference to the image.
  78.  *
  79.  * @param id        The ID for the image.
  80.  *
  81.  * @return A pointer to the requested image, or NULL if it was not found.
  82.  */
  83. PurpleStoredImage *purple_imgstore_find_by_id(int id);
  84.  
  85. /**
  86.  * Retrieves a pointer to the image's data.
  87.  *
  88.  * @param img    The Image
  89.  *
  90.  * @return A pointer to the data, which must not
  91.  *         be freed or modified.
  92.  */
  93. gconstpointer purple_imgstore_get_data(PurpleStoredImage *img);
  94.  
  95. /**
  96.  * Retrieves the length of the image's data.
  97.  *
  98.  * @param img    The Image
  99.  *
  100.  * @return The size of the data that the pointer returned by
  101.  *         purple_imgstore_get_data points to.
  102.  */
  103. size_t purple_imgstore_get_size(PurpleStoredImage *img);
  104.  
  105. /**
  106.  * Retrieves a pointer to the image's filename.
  107.  *
  108.  * @param img    The image
  109.  *
  110.  * @return A pointer to the filename, which must not
  111.  *         be freed or modified.
  112.  */
  113. const char *purple_imgstore_get_filename(const PurpleStoredImage *img);
  114.  
  115. /**
  116.  * Returns an extension corresponding to the image's file type.
  117.  *
  118.  * @param img  The image.
  119.  *
  120.  * @return The icon's extension or "icon" if unknown.
  121.  */
  122. const char *purple_imgstore_get_extension(PurpleStoredImage *img);
  123.  
  124. /**
  125.  * Increment the reference count.
  126.  *
  127.  * @param img The image.
  128.  *
  129.  * @return @a img
  130.  */
  131. PurpleStoredImage *
  132. purple_imgstore_ref(PurpleStoredImage *img);
  133.  
  134. /**
  135.  * Decrement the reference count.
  136.  *
  137.  * If the reference count reaches zero, the image will be freed.
  138.  *
  139.  * @param img The image.
  140.  *
  141.  * @return @a img or @c NULL if the reference count reached zero.
  142.  */
  143. PurpleStoredImage *
  144. purple_imgstore_unref(PurpleStoredImage *img);
  145.  
  146. /**
  147.  * Increment the reference count using an ID.
  148.  *
  149.  * This is a convience wrapper for purple_imgstore_find_by_id() and
  150.  * purple_imgstore_ref(), so if you have a PurpleStoredImage, it'll
  151.  * be more efficient to call purple_imgstore_ref() directly.
  152.  *
  153.  * @param id        The ID for the image.
  154.  */
  155. void purple_imgstore_ref_by_id(int id);
  156.  
  157. /**
  158.  * Decrement the reference count using an ID.
  159.  *
  160.  * This is a convience wrapper for purple_imgstore_find_by_id() and
  161.  * purple_imgstore_unref(), so if you have a PurpleStoredImage, it'll
  162.  * be more efficient to call purple_imgstore_unref() directly.
  163.  *
  164.  * @param id        The ID for the image.
  165.  */
  166. void purple_imgstore_unref_by_id(int id);
  167.  
  168. /**
  169.  * Returns the image store subsystem handle.
  170.  *
  171.  * @return The subsystem handle.
  172.  */
  173. void *purple_imgstore_get_handle(void);
  174.  
  175. /**
  176.  * Initializes the image store subsystem.
  177.  */
  178. void purple_imgstore_init(void);
  179.  
  180. /**
  181.  * Uninitializes the image store subsystem.
  182.  */
  183. void purple_imgstore_uninit(void);
  184.  
  185. #ifdef __cplusplus
  186. }
  187. #endif
  188.  
  189. #endif /* _PURPLE_IMGSTORE_H_ */
  190.